package leetcode;

import java.util.Arrays;

/**
 * @author Liangyaoyun
 */
public class leetCode2357 {
    public int minimumOperations(int[] nums) {
        Arrays.sort(nums);
        int min=0;
        int count=0;
        int max=0;
        int sum=0;
        if (nums.length==1&&nums[0]==0){
            return 0;
        }
        if (nums.length==1){
            return 1;
        }
        if (nums.length>1){
            max=nums[nums.length-2];
        }
        for (int j = 0; j < nums.length; j++) {
            if (sum>=max){
                break;
            }
            if (nums[j]>0){
                int k=nums[j];
                count++;
                sum+=k;
                for (int l = 0; l < nums.length; l++) {
                    nums[l]-=k;
                }
            }
        }
        return count;
    }
}
